﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PcapDemo
{
    public class HttpPacketPieceManager
    {
        public List<HttpPacketPiece> _httpPacketPieces = new List<HttpPacketPiece>();

        public void Add(HttpPacketPiece obj)
        {
            HttpPacketPiece piece = _httpPacketPieces.FirstOrDefault(x => x.AcknowledgmentNumber == obj.AcknowledgmentNumber);
            if (null == piece)
            {
                _httpPacketPieces.Add(obj);
                return;
            }
            piece.Bytes = piece.Bytes.Concat(obj.Bytes).ToArray();
            piece.Psh = obj.Psh;
            piece.Length = piece.Length + obj.Length;
        }
    }
}
